
!function(bool) {

	if (bool) {

		window.constructor.prototype.__defineGetter__("event", function() {
			var o = arguments.callee;
			do {
				if (o.arguments[0] instanceof Event)
					return o.arguments[0];
			} while (o = o.caller);
			return null;
		});
	}
}(/Firefox/.test(window.navigator.userAgent));

var ylBase = {
	$ : function(id) {
		return document.getElementById(id)
	},
	tagArr : function(o, name) {
		return o.getElementsByTagName(name)
	},
	att : function(o, name, fun) {
		return document.all ? o.attachEvent(name, fun) : o.addEventListener(
				name.substr(2), fun, false);
	},
	style : function(o) {
		return o.currentStyle || document.defaultView.getComputedStyle(o, null);
	},
	className : function(obj, name) {
		var str = [];
		this.cyc(this.tagArr(obj, '*'), function(obj) {
			if (obj.className == name) {
				str[str.length] = obj;
			}
		})
		return str;
	},
	cyc : function(arr, fun, length) {
		var len = arr.length, i = 0;
		if (len && length && len > length)
			len = length;
		for (; i < len; i++) {
			fun(arr[i]);
		}
	},
	rePreviousSibling : function(o) {
		do {
			o = o.previousSibling;
		} while (o && (o.nodeType != 1));
		return o;
	},
	reNextSibing : function(o) {
		do {
			o = o.nextSibling;
		} while (o && (o.nodeType != 1));
		return o;
	},
	dElement : function() {
		return document.documentElement || document.body;
	},
	position : function() {
		return {
			'x' : event.pageX || (event.clientX + this.dElement().scrollLeft),
			'y' : event.pageY || (event.clientY + this.dElement().scrollTop)
		}
	},
	retParScrollLeft : function(o) {
		var num = 0;
		try {
			do {
				o = o.parentNode;
				if (o.scrollLeft)
					num += o.scrollLeft;
			} while (o && o.scrollLeft != undefined && o.scrollLeft == 0);
		} catch (exception) {
		}
		return num;
	},
	offsetLT : function(o) {
		var x = 0, y = 0;
		do {
			x += o.offsetLeft, y += o.offsetTop;
		} while (o = o.offsetParent);
		return {
			'x' : x,
			'y' : y
		};
	},
	buildElement : function(tagName, parentObj) {
		var obj = document.createElement(tagName);
		parentObj.appendChild(obj);
		return obj;
	},
	alpha : function(o, num) {
		o.style.filter = 'alpha(opacity=' + num + ')';
		o.style.opacity = num / 100;
	},
	rewriteAtt : function(formerObj, newObj) {
		for ( var i in newObj) {
			formerObj[i] = newObj[i];
		}
		return formerObj;
	},
	replace : function(text, arr1, arr2) {
		var len = arr1.length, i = 0;
		for (; i < len; i++) {
			text = text.replace(eval('/' + arr1[i] + '/g'), arr2[i]);
		}
		return text
	},
	getUrlParameter : function(url) {
		url = url.split('?')[1];
		if (!url) {
			return null;
		}
		var arr = url.split('&'), len = arr.length, i, object = {};
		for (i = 0; i < len; i++) {
			var text = arr[i].split('=');
			object[text[0]] = text[1];
		}
		return object;
	}
};

function tabBox(obj, name, tagName, onCss, offCss, fun) {
	var base = ylBase;
	var arr = base.tagArr(obj.parentNode, tagName), len = arr.length, i = 0, n = 0;
	for (; i < len; i++) {
		if (arr[i].className == onCss) {
			arr[i].className = offCss;
			base.$(name + i).style.display = 'none';
		}
		if (arr[i] == obj)
			n = i;
	}
	obj.className = onCss;
	base.$(name + n).style.display = 'block';
	fun && fun();
}

var searchData = function(newObj) {
	this.base = ylBase;
	var pro = this;
	pro = this.base.rewriteAtt(pro, newObj);
	this.get();
};
searchData.prototype = {
	get : function() {
		var matchType = [ 'search', 'shear', 'replace', 'del' ];
		if (!matchType[this.type])
			return;
		var data = this[matchType[this.type]]();
		this.getCallBack && this.getCallBack(data);

	},
	search : function() {
		return this.text.match(eval(this.regExp));
	},
	shear : function() {
		var text = this.text, str = [];
		text = text.replace(eval(this.regExp), function() {
			str[str.length] = arguments[0];
			return '';
		});
		return {
			data : str,
			text : text
		};
	},
	replace : function() {
		var text = this.text, pro = this;
		text = text.replace(eval(this.regExp), function() {
			return pro.replaceCallBack(arguments[0]);
		});
		return text;
	},
	del : function() {
		var text = this.text, str = [];
		text = text.replace(eval(this.regExp), '');
		return text;
	}
}
function showPic(obj, pic1, pic2) {
	var base = ylBase;
	if (obj.checked) {
		base.$(pic1).style.display = 'none';
		base.$(pic2).style.display = 'block';
	} else {
		base.$(pic1).style.display = 'block';
		base.$(pic2).style.display = 'none';
	}
}

function closeThis() {
	var base = parent.ylBase;
	var thisId = base.getUrlParameter(location.href).id;
	parent.popUpClose( [ thisId, thisId + '_bg' ]);
}

function initPageWH() {
	var base = ylBase;
	var idArr = [ 'bodyBox', 'leftBox', 'contractionBtnBox', 'rightBox',
			'rightIframe' ]
	var height = base.dElement().clientHeight - 97;
	base.cyc(idArr, function(id) {
		var obj = base.$(id);
		if (obj) {
			obj.style.height = height + 'px';
		}
	})
}

/**
 * 王尧喜:关闭弹窗,解决ie下超空间问题
 * 
 * @param myid
 * @return
 */
function closeMe(myid) {

	var selfDiv = window.parent.document.getElementById(myid);
	var selfBg = window.parent.document.getElementById(myid + "_bg");

	selfDiv.parentNode.removeChild(selfDiv);
	selfBg.parentNode.removeChild(selfBg);

	selfDiv.innerHTML = "";
	selfBg.innerHTML = "";

	selfDiv = null;
	selfBg = null;
}

/**
 * 王尧喜:注册String trim函数
 */
String.prototype.trim = function() {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

/**
 * 王尧喜:注册Array each函数
 */
Array.prototype.each = function(callback) {
	alert();
	for ( var i = 0, j = this.length; i < j; i++) {
		callback.call(this, this[i], i);
	}
}
